﻿
// MFCApplication1View.cpp: CMFCApplication1View 类的实现
//

#include "pch.h"
#include "framework.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义，并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "MFCApplication1.h"
#endif

#include "MFCApplication1Doc.h"
#include "MFCApplication1View.h"
#include "CLineAspectDialog.h"

#include "Graphic3d_Vec2.hxx"
#include "gp_Circ2d.hxx"
#include "gp_Sphere.hxx"
#include "Geom2d_Circle.hxx"
#include "Geom_SphericalSurface.hxx"
#include "Geom_Plane.hxx"
#include "Geom_RectangularTrimmedSurface.hxx"
#include "GeomAPI_PointsToBSpline.hxx"
#include "AIS_Axis.hxx"
#include "AIS_PlaneTrihedron.hxx"
#include "AIS_Trihedron.hxx"
#include "GCE2d_MakeArcOfCircle.hxx"
#include "BRepPrimAPI_MakeBox.hxx"
#include "IGESControl_Reader.hxx"
#include "STEPControl_Reader.hxx"
#include "StdSelect_FaceFilter.hxx"
#include <XSControl_WorkSession.hxx>
#include <XSControl_TransferReader.hxx>
#include <STEPConstruct_Styles.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <STEPConstruct.hxx>
#include <StepVisual_StyledItem.hxx>
#include "Resource_Unicode.hxx"
#include "StdSelect_MyFaceFilter.hxx"

#include "MakeBottle.h"

#include "Select_RoundSlotFilter.h"
#include "Select_RectSlotFilter.h"
#include "SelectionTool_RectSlot.h"

#include "OccUtility.h"

#include "resource.h"

//#ifdef _DEBUG
//#define new DEBUG_NEW
//#endif

// CMFCApplication1View

IMPLEMENT_DYNCREATE(CMFCApplication1View, CView)

BEGIN_MESSAGE_MAP(CMFCApplication1View, CView)
	// 标准打印命令
	ON_WM_LBUTTONUP()
	ON_WM_LBUTTONDOWN()
	ON_WM_SIZE()
	ON_WM_MBUTTONUP()
	ON_WM_MBUTTONDOWN()
	ON_WM_RBUTTONUP()
	ON_WM_RBUTTONDOWN()
	ON_WM_MOUSEMOVE()
	ON_WM_MOUSEWHEEL()
	ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
	ON_COMMAND(ID_TOP_VIEW, &CMFCApplication1View::OnTopView)
	ON_COMMAND(ID_CREATE_BOX, &CMFCApplication1View::OnCreateBox)
	ON_COMMAND(ID_CREATE_CYLINDER, &CMFCApplication1View::OnCreateCylinder)
	ON_COMMAND(ID_CREATE_SPHERE, &CMFCApplication1View::OnCreateSphere)
	ON_COMMAND(ID_CREATE_BOTTLE, &CMFCApplication1View::OnCreateBottle)
	ON_COMMAND(ID_SIDE_VIEW, &CMFCApplication1View::OnSideView)
	ON_COMMAND(ID_FRONT_VIEW, &CMFCApplication1View::OnFrontView)
	ON_COMMAND(ID_ISO_VIEW, &CMFCApplication1View::OnIsoView)
	ON_COMMAND(ID_FIT_ALL, &CMFCApplication1View::OnFitAll)
	ON_COMMAND(ID_2D_LINE, &CMFCApplication1View::On2dLine)
	ON_COMMAND(ID_2D_ARC, &CMFCApplication1View::On2dArc)
	ON_COMMAND(ID_3D_POINT, &CMFCApplication1View::On3dPoint)
	ON_COMMAND(ID_3D_LINE, &CMFCApplication1View::On3dLine)
	ON_COMMAND(ID_3D_SPLINE, &CMFCApplication1View::On3dSpline)
	ON_COMMAND(ID_PLANE, &CMFCApplication1View::OnPlane)
	ON_COMMAND(ID_CYLINDER, &CMFCApplication1View::OnCylinder)
	ON_COMMAND(ID_PARABOLA, &CMFCApplication1View::OnParabola)
	ON_UPDATE_COMMAND_UI(ID_SHOW_EDGE, &CMFCApplication1View::OnUpdateShowEdge)
	ON_COMMAND(ID_SHOW_EDGE, &CMFCApplication1View::OnShowEdge)
	ON_COMMAND(ID_LINE_ASPECT, &CMFCApplication1View::OnLineAspect)
	ON_COMMAND(ID_DATUM_CIRCLE, &CMFCApplication1View::OnDatumCircle)
	ON_COMMAND(ID_DATUM_AXIS, &CMFCApplication1View::OnDatumAxis)
	ON_COMMAND(ID_DATUM_PLANE, &CMFCApplication1View::OnDatumPlane)
	ON_COMMAND(ID_DATUM_TRIHEDRON, &CMFCApplication1View::OnDatumTrihedron)
	ON_COMMAND(ID_DATUM_POINT, &CMFCApplication1View::OnDatumPoint)
	ON_COMMAND(ID_SELECT_VERTEX, &CMFCApplication1View::OnSelectVertex)
	ON_COMMAND(ID_SELECT_FACE, &CMFCApplication1View::OnSelectFace)
	ON_COMMAND(ID_SELECT_EDGE, &CMFCApplication1View::OnSelectEdge)
	ON_COMMAND(ID_SELECT_SOLID, &CMFCApplication1View::OnSelectSolid)
	ON_COMMAND(ID_IMPORT_IGES_FILE, &CMFCApplication1View::OnImportIgesFile)
	ON_COMMAND(ID_IMPORT_STEP_FILE, &CMFCApplication1View::OnImportStepFile)
	ON_COMMAND(ID_SHOW_GRID, &CMFCApplication1View::OnShowGrid)
	ON_UPDATE_COMMAND_UI(ID_SHOW_GRID, &CMFCApplication1View::OnUpdateShowGrid)
	ON_COMMAND(ID_SELECT_ROUND_SLOT, &CMFCApplication1View::OnSelectRoundSlot)
	ON_COMMAND(ID_SELECT_RECT_SLOT, &CMFCApplication1View::OnRectSlotSelect)
	ON_UPDATE_COMMAND_UI(ID_SELECT_RECT_SLOT, &CMFCApplication1View::OnUpdateSelectRectSlot)
	ON_UPDATE_COMMAND_UI(ID_SELECT_ROUND_SLOT, &CMFCApplication1View::OnUpdateSelectRoundSlot)
	ON_COMMAND(ID_LINE_2_BSPLINE, &CMFCApplication1View::OnLine2Bspline)
	ON_COMMAND(ID_CIRCLE_2_BSPLINE, &CMFCApplication1View::OnCircle2Bspline)
	ON_COMMAND(ID_VIEW_ANIMATION, &CMFCApplication1View::OnViewAnimation)
	ON_COMMAND(ID_USER_DEFINED_2D_AIS_OBJECT, &CMFCApplication1View::OnUserDefined2dAisObject)
	ON_COMMAND(ID_3D_POINT_TO_2D_POINT, &CMFCApplication1View::On3dPointTo2dPoint)
	ON_COMMAND(ID_FIXED_GRID, &CMFCApplication1View::OnFixedGrid)
	ON_COMMAND(ID_POINT_CLOUD, &CMFCApplication1View::OnPointCloud)
	ON_COMMAND(ID_CONE, &CMFCApplication1View::OnCone)
	ON_COMMAND(ID_ISO_SURFACE, &CMFCApplication1View::OnIsoSurface)
END_MESSAGE_MAP()

// CMFCApplication1View 构造/析构

CMFCApplication1View::CMFCApplication1View() noexcept:
	myFixedGrid(nullptr),
	m_pSelectionTool(NULL),
	myShowEdge(Standard_False),
	myShowGrid(Standard_False),
	myCurrentMode(CurAction3d_Nothing)
{
	Handle(Graphic3d_GraphicDriver) theGraphicDriver = ((CMFCApplication1App*)AfxGetApp())->GetGraphicDriver();

	myViewer = new V3d_Viewer(theGraphicDriver);
	myViewer->SetDefaultLights();
	myViewer->SetLightOn();

	myAisContext = new AIS_InteractiveContext(myViewer);
	myAisShape.Nullify();

	myAisContext->SetDisplayMode(AIS_Shaded, true);
	myAisContext->SetAutomaticHilight(Standard_True);
	myZLayerID = -10;
}

CMFCApplication1View::~CMFCApplication1View()
{
}

BOOL CMFCApplication1View::PreCreateWindow(CREATESTRUCT& cs)
{
	return CView::PreCreateWindow(cs);
}

// CMFCApplication1View 绘图

void CMFCApplication1View::OnDraw(CDC* /*pDC*/)
{
	CMFCApplication1Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	myView->InvalidateImmediate();
	FlushViewEvents(myAisContext, myView, true);

	//myView->MustBeResized();
	//myView->Update();
}


// CMFCApplication1View 打印

BOOL CMFCApplication1View::OnPreparePrinting(CPrintInfo* pInfo)
{
	return DoPreparePrinting(pInfo);
}

void CMFCApplication1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}

void CMFCApplication1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}


// CMFCApplication1View 诊断

#ifdef _DEBUG
void CMFCApplication1View::AssertValid() const
{
	CView::AssertValid();
}

void CMFCApplication1View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMFCApplication1Doc* CMFCApplication1View::GetDocument() const // 非调试版本是内联的
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMFCApplication1Doc)));
	return (CMFCApplication1Doc*)m_pDocument;
}
#endif //_DEBUG

void CMFCApplication1View::InitTriedron()
{
	// 坐标系
	myView->ZBufferTriedronSetup(Quantity_NOC_RED, Quantity_NOC_GREEN, Quantity_NOC_BLUE1, 1, 0.05, 50);
	myView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.15, V3d_ZBUFFER/*,Standard_False*/);
}

void CMFCApplication1View::InitBgColors()
{
	const Quantity_Color theColor1(0.992, 0.992, 0.992, Quantity_TOC_RGB);
	const Quantity_Color theColor2(0.715, 0.715, 0.715, Quantity_TOC_RGB);
	myView->SetBgGradientColors(theColor1, theColor2, Aspect_GFM_HOR, Standard_True);
}

void CMFCApplication1View::OnInitialUpdate() {

	CView::OnInitialUpdate();

	myView = GetViewer()->CreateView();
	myView->SetShadingModel(V3d_GOURAUD);
	myView->SetImmediateUpdate(false);
	myView->SetComputedMode(Standard_False);
	myView->SetProj(V3d_Zpos);

	Handle(Graphic3d_GraphicDriver) theGraphicDriver = ((CMFCApplication1App*)AfxGetApp())->GetGraphicDriver();

	Aspect_Handle aWindowHandle = (Aspect_Handle)GetSafeHwnd();
	Handle(WNT_Window) aWntWindow = new WNT_Window(GetSafeHwnd());

	Graphic3d_ZLayerSettings aSettings;
	aSettings.SetName("My2dShape");
	aSettings.SetImmediate(Standard_False);
	aSettings.SetRaytracable(Standard_False);
	aSettings.SetEnvironmentTexture(Standard_False);
	aSettings.SetEnableDepthTest(Standard_False);
	aSettings.SetEnableDepthWrite(Standard_False);
	aSettings.SetClearDepth(Standard_False);
	aSettings.SetPolygonOffset(Graphic3d_PolygonOffset());
	Standard_Boolean ok = myViewer->AddZLayer(myZLayerID, aSettings);

	TColStd_SequenceOfInteger aLayers;
	myViewer->GetAllZLayers(aLayers);
	for (TColStd_SequenceOfInteger::Iterator aLayeriter(aLayers); aLayeriter.More(); aLayeriter.Next())
	{
		TRACE("\n【ZLayer】%d\n", aLayeriter.Value());
		Graphic3d_ZLayerSettings aSettings = myViewer->ZLayerSettings(aLayeriter.Value());
	}

	myView->SetWindow(aWntWindow);
	if (!aWntWindow->IsMapped()) {
		aWntWindow->Map();
	}

	Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(theGraphicDriver);
	myView->Camera()->SetProjectionType(Graphic3d_Camera::Projection_Orthographic);
	myView->Camera()->SetFOV2d(1800);

	Standard_Integer w = 100;
	Standard_Integer h = 100;
	aWntWindow->Size(w, h);
	::PostMessage(GetSafeHwnd(), WM_SIZE, SIZE_RESTORED, w + h * 65536);

	InitTriedron();

	InitBgColors();

	myView->FitAll();
}

void CMFCApplication1View::OnShowGrid()
{
	myShowGrid = !myShowGrid;

	myShowGrid ? myViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Lines) :
		myViewer->DeactivateGrid();
	myViewer->Redraw();
}


void CMFCApplication1View::OnUpdateShowGrid(CCmdUI *pCmdUI)
{
	pCmdUI->SetCheck(myShowGrid);
}


void CMFCApplication1View::UpdateOccView()
{
	if (!myView.IsNull())
	{
//		if (++myUpdateRequests == 1)
//		{
			Invalidate(FALSE);
			UpdateWindow();
//		}
	}
}

// CMFCApplication1View 消息处理程序

void CMFCApplication1View::OnTopView()
{
	if (!myView.IsNull()) {
		myView->SetProj(V3d_Zneg);
	}
}

void CMFCApplication1View::OnSideView()
{
	if (!myView.IsNull()) {
		myView->SetProj(V3d_Xpos);
	}
}

void CMFCApplication1View::OnFrontView()
{
	if (!myView.IsNull()) {
		myView->SetProj(V3d_Yneg);
	}
}

void CMFCApplication1View::OnIsoView()
{
	if (!myView.IsNull()) {
		myView->SetProj(V3d_XposYnegZpos);
	}
}

void CMFCApplication1View::OnFitAll()
{
	if (!myView.IsNull()) {
		myView->FitAll();
	}
}

TopoDS_Shape CMFCApplication1View::ReverseFaceOrientation(const TopoDS_Shape& shape, const TopoDS_Face& face)
{
	Handle(BRepTools_ReShape) rebuild = new BRepTools_ReShape;
	TopoDS_Shape newface = face.Complemented();
	rebuild->Replace(face, newface);
	TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_FACE);
	return newshape;
}

#include "ShapeFix_Face.hxx"
#include "BRepTools_Quilt.hxx"
#include "GeomLProp_SLProps.hxx"
#include "AIS_IsoGridFace.h"

void CMFCApplication1View::OnLButtonDown(UINT nFlags, CPoint point)
{
	const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent(nFlags);
	PressMouseButton(Graphic3d_Vec2i(point.x, point.y), Aspect_VKeyMouse_LeftButton, aFlags, false);

	switch (getCurrentAction())
	{
	case CurAction3d_Nothing:
		setCurrentAction(CurAction3d_DynamicRotation);
		myView->StartRotation(point.x, point.y);
		break;
	case CurAction3d_FaceSelection:
	{
		myAisContext->InitSelected();

		TopoDS_Shape aShape = myAisContext->SelectedShape();
		TopoDS_Face& aFace = TopoDS::Face(aShape);

		Handle(AIS_IsoGridFace) aIsoFace = new AIS_IsoGridFace(aFace);

		myAisContext->Display(aIsoFace, Standard_True);


	}
	break;
	case CurAction3d_EdgeSelection:
	{
		myAisContext->InitSelected();
		TopoDS_Shape  aShape = myAisContext->SelectedShape();

		BRepTools::Dump(aShape, std::cout);
//		occ_utility::PrintEdgeInfo(TopoDS::Edge(aShape));
		OnSelectEdge();
	}
	case CurAction3d_SolidSelection:
	{
		myAisContext->InitSelected();
		TopoDS_Shape  aShape = myAisContext->SelectedShape();

		BRepTools::Dump(aShape, std::cout);
	}

	case CurAction3d_SelectionTool:
	{
		if (m_pSelectionTool)
			m_pSelectionTool->Pick(point.x, point.y, myView);

	}

	default:
		break;
	}
}

void CMFCApplication1View::OnLButtonUp(UINT nFlags, CPoint point)
{
	const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent(nFlags);
	ReleaseMouseButton(Graphic3d_Vec2i(point.x, point.y), Aspect_VKeyMouse_LeftButton, aFlags, false);

	UpdateOccView();

	if (myCurrentMode != CurAction3d_Nothing)
	{
		setCurrentAction(CurAction3d_Nothing);
	}
}

void CMFCApplication1View::OnMButtonDown(UINT nFlags, CPoint point)
{
	myXmin = point.x;  myYmin = point.y;
	myXmax = point.x;  myYmax = point.y;

	setCurrentAction(CurAction3d_DynamicPanning);
}

void CMFCApplication1View::OnMButtonUp(UINT nFlags, CPoint point)
{
	if (myCurrentMode != CurAction3d_Nothing)
	{
		setCurrentAction(CurAction3d_Nothing);
	}
}

void CMFCApplication1View::OnRButtonDown(UINT nFlags, CPoint point)
{
	myXmin = point.x;  myYmin = point.y;
	myXmax = point.x;  myYmax = point.y;

	setCurrentAction(CurAction3d_DynamicZooming);
}

void CMFCApplication1View::OnRButtonUp(UINT nFlags, CPoint point)
{
	if (myCurrentMode != CurAction3d_Nothing)
	{
		setCurrentAction(CurAction3d_Nothing);
	}
}

void CMFCApplication1View::OnMouseMove(UINT nFlags, CPoint point)
{
	TRACKMOUSEEVENT aMouseEvent;          // for WM_MOUSELEAVE
	aMouseEvent.cbSize = sizeof(aMouseEvent);
	aMouseEvent.dwFlags = TME_LEAVE;
	aMouseEvent.hwndTrack = m_hWnd;
	aMouseEvent.dwHoverTime = HOVER_DEFAULT;
	if (!::_TrackMouseEvent(&aMouseEvent)) { TRACE("Track ERROR!\n"); }

	const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent(nFlags);
	if (UpdateMousePosition(Graphic3d_Vec2i(point.x, point.y), PressedMouseButtons(), aFlags, false))
	{
		UpdateOccView();
	}

	switch (getCurrentAction())
	{
	case CurAction3d_DynamicRotation:
		myView->Rotation(point.x, point.y);
		myView->Redraw();
		break;
	case CurAction3d_DynamicPanning:
		myView->Pan(point.x - myXmax, myYmax - point.y); // Realize the panning
		myXmax = point.x; myYmax = point.y;
		break;
	case CurAction3d_DynamicZooming:
		myView->Zoom(myXmax, myYmax, point.x, point.y);
		UpdateGrid();
		myXmax = point.x;  myYmax = point.y;
		break;
	case CurAction3d_VertexSelection:
	case CurAction3d_EdgeSelection:
	case CurAction3d_FaceSelection:
	case CurAction3d_SolidSelection:
		myAisContext->MoveTo(point.x, point.y, myView, Standard_False);
		myAisContext->Select(Standard_True);
		break;
	case CurAction3d_SelectionTool:
		if (m_pSelectionTool)
			m_pSelectionTool->Move(point.x, point.y, myView);
		break;
	default:
		break;
	}
}

void CMFCApplication1View::OnCreateBox()
{
	TopoDS_Shape box = BRepPrimAPI_MakeBox(200, 300, 80).Shape();
	ShowTopoDsShape(box);
}

void CMFCApplication1View::OnCreateCylinder()
{
	TopoDS_Shape cylinder = BRepPrimAPI_MakeCylinder(100, 30).Shape();
	ShowTopoDsShape(cylinder);
}

void CMFCApplication1View::OnCreateSphere()
{
	TopoDS_Shape sphere = BRepPrimAPI_MakeSphere(150).Shape();
	ShowTopoDsShape(sphere);
}

void CMFCApplication1View::OnCreateBottle()
{
	TopoDS_Shape bottle = MakeBottle(300,500,150);
	ShowTopoDsShape(bottle);
}

#define FEATURE_COLOR_FRONT_SIDE	Quantity_Color(1, 1, 0, Quantity_TOC_RGB)
#define FEATURE_COLOR_BACK_SIDE		Quantity_Color(0, 0, 0.84, Quantity_TOC_RGB)

void CMFCApplication1View::SetShapeColor(Handle(AIS_Shape) shape)
{
	myAisShape->Attributes()->SetUIsoAspect(new Prs3d_IsoAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 2.0f, 5));
	myAisShape->Attributes()->SetVIsoAspect(new Prs3d_IsoAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 2.0f, 5));
	
	myAisContext->SetDisplayMode(myAisShape, 2, Standard_False);

	//Handle(Prs3d_ShadingAspect) sa = shape->Attributes()->ShadingAspect();

	//sa->SetColor(FEATURE_COLOR_BACK_SIDE, Aspect_TOFM_BACK_SIDE);
	//sa->SetColor(FEATURE_COLOR_FRONT_SIDE, Aspect_TOFM_FRONT_SIDE);

//	shape->Attributes()->SetShadingAspect(sa);
}

void CMFCApplication1View::ShowTopoDsShape(TopoDS_Shape shape)
{
	myAisContext->RemoveAll(Standard_True);

	myAisShape = new AIS_Shape(shape);

	SetShapeColor(myAisShape);

	myAisContext->Display(myAisShape, Standard_True);
}

void CMFCApplication1View::ShowAisInteractiveShape(Handle(AIS_InteractiveObject) aAisInteractiveShape)
{
	myAisContext->RemoveAll(Standard_True);

	myAisContext->Display(aAisInteractiveShape, Standard_True);
}

void CMFCApplication1View::On2dLine()
{
	//	二维直线段
	gp_Pnt2d p1(0, 100);		//	端点1
	gp_Pnt2d p2(320, 100);		//	端点2
	Handle(Geom2d_TrimmedCurve) pTrimmedCurve = GCE2d_MakeSegment(p1, p2).Value();
	
	//	二维直线所在平面
	gp_Pnt P(0, 0, 0);
	gp_Vec V(0, 0, 1);
	Handle(Geom_Plane) pPlane = new Geom_Plane(P, V);

	TopoDS_Edge E = BRepBuilderAPI_MakeEdge(pTrimmedCurve, pPlane);
	ShowTopoDsShape(E);
}

#include "AIS_Circle.hxx"
void CMFCApplication1View::On2dArc()
{
	//	二维圆弧
	gp_Pnt2d P1(0, 200);		//	端点1
	gp_Pnt2d P2(141.4, 141.4);	//	中间点
	gp_Pnt2d P3(200, 0);		//	端点2
	Handle(Geom2d_Curve) arc = GCE2d_MakeArcOfCircle(P1, P2, P3).Value();

	//	二维直线所在平面
	gp_Pnt P(0, 0, 0);
	gp_Vec V(0, 0, 1);
	Handle(Geom_Plane) pPlane = new Geom_Plane(P, V);

	TopoDS_Edge E = BRepBuilderAPI_MakeEdge(arc, pPlane);
	ShowTopoDsShape(E);
}

void CMFCApplication1View::On3dPoint()
{
	TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(-20, 10, -30));
	ShowTopoDsShape(aVertex);
}

void CMFCApplication1View::On3dLine()
{
	gp_Lin line(gp_Ax1(gp_Pnt(10, 10, 10), gp_Dir(1, 0, 0)));
	TopoDS_Edge E = BRepBuilderAPI_MakeEdge(line, -20, 10);
	ShowTopoDsShape(E);
}

void CMFCApplication1View::On3dSpline()
{
	gp_Pnt P1(0, 0, 100);
	gp_Pnt P2(100, 50, 200);
	gp_Pnt P3(200, 130, 300);
	gp_Pnt P4(240, -300, 400);
	gp_Pnt P5(250, -450, 500);
	TColgp_Array1OfPnt array(1, 5); // sizing array
	array.SetValue(1, P1);
	array.SetValue(2, P2);
	array.SetValue(3, P3);
	array.SetValue(4, P4);
	array.SetValue(5, P5);
	Handle(TColgp_HArray1OfPnt) harray =
		new TColgp_HArray1OfPnt(1, 5); // sizing harray
	harray->SetValue(1, P1.Translated(gp_Vec(4, 0, 0)));
	harray->SetValue(2, P2.Translated(gp_Vec(4, 0, 0)));
	harray->SetValue(3, P3.Translated(gp_Vec(4, 0, 0)));
	harray->SetValue(4, P4.Translated(gp_Vec(4, 0, 0)));
	harray->SetValue(5, P5.Translated(gp_Vec(4, 0, 0)));
	Handle(Geom_BSplineCurve) SPL1 =
		GeomAPI_PointsToBSpline(array).Curve();

	TopoDS_Edge E = BRepBuilderAPI_MakeEdge(SPL1).Edge();
	ShowTopoDsShape(E);
}

void CMFCApplication1View::OnPlane()
{
	gp_Pnt P(0, 0, 200);
	gp_Vec V(0, 0, 1);
	Handle(Geom_Plane) Pi = new Geom_Plane(P, V);
	Handle(Geom_RectangularTrimmedSurface) Surface = new Geom_RectangularTrimmedSurface(Pi, -100., 100., -100., 100.);
	TopoDS_Face F = BRepBuilderAPI_MakeFace(Surface, Precision::Confusion());
	ShowTopoDsShape(F);
}

void CMFCApplication1View::OnCylinder()
{
	gp_Ax3 P(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1));
	Standard_Real r = 100.0;
	Handle(Geom_CylindricalSurface) Pi = new Geom_CylindricalSurface(P, r);
	Handle(Geom_RectangularTrimmedSurface) Surface = new Geom_RectangularTrimmedSurface(Pi, -100., 100., -100., 100.);
	TopoDS_Face F = BRepBuilderAPI_MakeFace(Surface, Precision::Confusion());
	ShowTopoDsShape(F);
}

void CMFCApplication1View::OnParabola()
{
	gp_Sphere sphere(gp_Ax3(gp_Pnt(-80, 0, 0), gp_Dir(1, 0, 0)), 150);
	Handle(Geom_SphericalSurface) Surface = new Geom_SphericalSurface(sphere);
	TopoDS_Face F = BRepBuilderAPI_MakeFace(Surface, Precision::Confusion());
	ShowTopoDsShape(F);
}

void CMFCApplication1View::OnUpdateShowEdge(CCmdUI *pCmdUI)
{
	pCmdUI->SetCheck(myShowEdge);
}


void CMFCApplication1View::OnShowEdge()
{
	myShowEdge = !myShowEdge;

	Handle(Prs3d_Drawer) drawer = myAisContext->DefaultDrawer();
	drawer->SetFaceBoundaryDraw(myShowEdge);
	myAisContext->Redisplay(AIS_KOI_Shape, -1, Standard_True);
}

void CMFCApplication1View::OnLineAspect()
{
	CLineAspectDialog dlg;
	if (dlg.DoModal() == IDOK)
	{

	}
}

void CMFCApplication1View::OnDatumCircle()
{
	Handle(Geom_Circle) C = new Geom_Circle(gp_Ax2(gp_Pnt(100, 0, 100), gp_Dir(1, -1, 0)), 50);
	Handle(AIS_InteractiveObject) circle = new AIS_Circle(C);

	ShowAisInteractiveShape(circle);
}

void CMFCApplication1View::OnDatumAxis()
{
	Handle(Geom_Line) L = new Geom_Line(gp_Ax1(gp_Pnt(0, 100, 100), gp_Dir(1, -1, 1)));
	Handle(AIS_Axis) ax1 = new AIS_Axis(L);

	ShowAisInteractiveShape(ax1);
}


void CMFCApplication1View::OnDatumPlane()
{
	Handle(Geom_Plane) Pl = new Geom_Plane(gp_Pnt(0, 0, 100), gp_Dir(0, 0, 1));
	Handle(AIS_PlaneTrihedron) plane = new AIS_PlaneTrihedron(Pl);
	plane->SetLength(100);

	ShowAisInteractiveShape(plane);
}


void CMFCApplication1View::OnDatumTrihedron()
{
	static int i = 0;
	Handle(Geom_Axis2Placement) axis2placement = new Geom_Axis2Placement(gp_Pnt(0, 0, 100), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0));
	Handle(AIS_Trihedron) trihedron = new AIS_Trihedron(axis2placement);

	trihedron->SetDatumDisplayMode(Prs3d_DatumMode(i=i++%2));
	trihedron->SetSize(60);
	trihedron->SetXAxisColor(Quantity_Color(Quantity_NOC_RED));
	trihedron->SetYAxisColor(Quantity_Color(Quantity_NOC_GREEN));
	trihedron->SetAxisColor(Quantity_Color(Quantity_NOC_BLUE));

	ShowAisInteractiveShape(trihedron);
}

void CMFCApplication1View::OnDatumPoint()
{
	static int i = 0;
	Handle(Geom_CartesianPoint) P = new Geom_CartesianPoint(gp_Pnt(0, 0, 100));
	Handle(AIS_Point) point = new AIS_Point(P);
	point->SetMarker(Aspect_TypeOfMarker(i = i++ % 14));

	ShowAisInteractiveShape(point);
}

void CMFCApplication1View::OnSelectVertex()
{
	myCurrentMode = CurAction3d_VertexSelection;

	const int aSubShapeSelMode = AIS_Shape::SelectionMode(TopAbs_VERTEX);
	myAisContext->Deactivate();
	myAisContext->Activate(aSubShapeSelMode);
	myAisContext->SetAutomaticHilight(Standard_True);
}

void CMFCApplication1View::OnSelectFace()
{
	myCurrentMode = CurAction3d_FaceSelection;

	myAisContext->Deactivate();
	myAisContext->Activate(AIS_Shape::SelectionMode(TopAbs_FACE));

	Handle(Prs3d_Drawer) t_hilight_style = myAisContext->HighlightStyle();
	t_hilight_style->SetMethod(Aspect_TOHM_COLOR);  // 颜色显示方式
	t_hilight_style->SetColor(Quantity_NOC_GREEN);  // 设置高亮颜色
	t_hilight_style->SetDisplayMode(AIS_Shaded);	// 整体高亮
	myAisContext->SetHighlightStyle(Prs3d_TypeOfHighlight_LocalSelected, t_hilight_style);
	myAisContext->SetAutomaticHilight(Standard_True);
}

void CMFCApplication1View::OnSelectEdge()
{
	myCurrentMode = CurAction3d_EdgeSelection;

	const int aSubShapeSelMode = AIS_Shape::SelectionMode(TopAbs_EDGE);

	myAisContext->Deactivate();
	myAisContext->Activate(aSubShapeSelMode);
	myAisContext->SetAutomaticHilight(Standard_True);
}

void CMFCApplication1View::OnSelectSolid()
{
	myCurrentMode = CurAction3d_SolidSelection;

	const int aSubShapeSelMode = AIS_Shape::SelectionMode(TopAbs_SOLID);
	myAisContext->Deactivate();
	myAisContext->Activate(aSubShapeSelMode);
	myAisContext->SetAutomaticHilight(Standard_True);
}

void CMFCApplication1View::OnImportIgesFile()
{
	const TCHAR* filter = _T("IGES文件*.IGES|*.iges|IGS文档*.IGS|*.igs|所有文件(*.*)|*.*||");

	CFileDialog dlg(TRUE, _T("iges"), NULL, 0, filter);
	if (dlg.DoModal() != IDOK)
		return;

//	std::string aFileName = CT2A((dlg.GetPathName()).GetString());
	TCollection_AsciiString aFileName((const wchar_t*)dlg.GetPathName());

	IGESControl_Reader aReader;
	Standard_Integer status = aReader.ReadFile(aFileName.ToCString());
	if (status != IFSelect_RetDone)
	{
		AfxMessageBox(L"读入IGES文件失败");
		return;
	}

	aReader.TransferRoots();

	TopoDS_Shape aTopoShape = aReader.OneShape();
	Handle(AIS_Shape) anAisShape = new AIS_Shape(aTopoShape);

	myAisContext->Display(anAisShape, Standard_False);
	myView->FitAll();
}


IFSelect_ReturnStatus CMFCApplication1View::ReadSTEP(const Standard_CString& aFileName,
	Handle(TopTools_HSequenceOfShape)& aHSequenceOfShape)
{
	aHSequenceOfShape->Clear();

	// create additional log file
	STEPControl_Reader aReader;
	IFSelect_ReturnStatus status = aReader.ReadFile(aFileName);
	if (status != IFSelect_RetDone)
		return status;

	aReader.WS()->TransferReader()->TransientProcess()->SetTraceLevel(2); // increase default trace level

	Standard_Boolean failsonly = Standard_False;
	aReader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity);

	// Root transfers
	Standard_Integer nbr = aReader.NbRootsForTransfer();
	aReader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity);
	for (Standard_Integer n = 1; n <= nbr; n++) {
		/*Standard_Boolean ok =*/ aReader.TransferRoot(n);
	}

	// Collecting resulting entities
	Standard_Integer nbs = aReader.NbShapes();
	if (nbs == 0) {
		return IFSelect_RetVoid;
	}

	std::ofstream of("d:\\info.txt");
	for (Standard_Integer i = 1; i <= nbs; i++) {
		aHSequenceOfShape->Append(aReader.Shape(i));

		occ_utility::SaveWiresInfo(of, aReader.Shape(i), 4, Standard_False);

		Handle(AIS_Shape) aShape = new AIS_Shape(aReader.Shape(i));

		vShapes.push_back(aShape);

		Handle(Prs3d_ShadingAspect) sa = aShape->Attributes()->ShadingAspect();

		sa->SetColor(FEATURE_COLOR_BACK_SIDE, Aspect_TOFM_BACK_SIDE);
		sa->SetColor(FEATURE_COLOR_FRONT_SIDE, Aspect_TOFM_FRONT_SIDE);

		aShape->Attributes()->SetShadingAspect(sa);

		myAisContext->Display(aShape, Standard_False);
	}
	of.close();

	TRACE(L"[Shape总数]%d\n", nbs);

	return status;
}

#include <fstream>
void CMFCApplication1View::SaveTopoInfo(const TopoDS_Shape& aTopoDsShape)
{
	

}

void CMFCApplication1View::OnImportStepFile()
{
	const TCHAR* filter = _T("STEP文件*.STEP|*.step|STP文档*.STP|*.stp|所有文件(*.*)|*.*||");

	CFileDialog dlg(TRUE, _T("STEP"), NULL, 0, filter);
	if (dlg.DoModal() != IDOK)
		return;

	Handle(TopTools_HSequenceOfShape) aSequence = new TopTools_HSequenceOfShape();

	TCollection_AsciiString aFileName((const wchar_t*)dlg.GetPathName());
	IFSelect_ReturnStatus ReturnStatus = ReadSTEP(aFileName.ToCString(), aSequence);

	switch (ReturnStatus)
	{
	case IFSelect_RetError:
		AfxMessageBox(L"Not a valid Step file");
		break;
	case IFSelect_RetFail:
		AfxMessageBox(L"Reading has failed");
		break;
	case IFSelect_RetVoid:
		AfxMessageBox(L"Nothing to transfer");
		break;
	}

	myView->FitAll();
}

void CMFCApplication1View::OnSelectRoundSlot()
{
	if (!m_pSelectionTool)
		m_pSelectionTool = new SelectionTool(myAisContext);

	m_pSelectionTool->Initialize(TopAbs_WIRE, new Select_RoundSlotFilter(myFaceList));

	setCurrentAction(CurAction3d_SelectionTool);
}


void CMFCApplication1View::OnRectSlotSelect()
{
	if (!m_pSelectionTool)
		m_pSelectionTool = new SelectionTool_RectSlot(myAisContext);

	((SelectionTool_RectSlot* )m_pSelectionTool)->Initialize(new Select_RectSlotFilter(myFaceList));

	setCurrentAction(CurAction3d_SelectionTool);
}


void CMFCApplication1View::OnUpdateSelectRectSlot(CCmdUI *pCmdUI)
{
	Handle(SelectMgr_Filter) filter = m_pSelectionTool!=NULL ? m_pSelectionTool->GetFilter():NULL;
	BOOL bChecked = (myCurrentMode == CurAction3d_SelectionTool) && 
		m_pSelectionTool->GetFilter().IsNull() == Standard_False &&
		m_pSelectionTool->GetFilter()->IsKind(STANDARD_TYPE(Select_RectSlotFilter));

	pCmdUI->SetCheck(bChecked);
}


void CMFCApplication1View::OnUpdateSelectRoundSlot(CCmdUI *pCmdUI)
{
	Handle(SelectMgr_Filter) filter = m_pSelectionTool != NULL ? m_pSelectionTool->GetFilter() : NULL;
	BOOL bChecked = (myCurrentMode == CurAction3d_SelectionTool) &&
		m_pSelectionTool->GetFilter().IsNull() == Standard_False &&
		m_pSelectionTool->GetFilter()->IsKind(STANDARD_TYPE(Select_RoundSlotFilter));

	pCmdUI->SetCheck(bChecked);
}

#include "GeomConvert.hxx"
void CMFCApplication1View::OnLine2Bspline()
{
	Handle(Geom_Line) aLine = new Geom_Line(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1));
	Handle(Geom_TrimmedCurve) aTrimmedCurve = new Geom_TrimmedCurve(aLine, -100, 100);
	Handle(Geom_BSplineCurve) aBSpline = GeomConvert::CurveToBSplineCurve(aTrimmedCurve);

	TopoDS_Edge E = BRepBuilderAPI_MakeEdge(aBSpline).Edge();
	ShowTopoDsShape(E);

	BRepAdaptor_Curve C;
	C.Initialize(E);

	Standard_Real u1 = C.FirstParameter();
	Standard_Real u2 = C.LastParameter();

	TRACE(L">>>>>>>>>>>>>>>>>[直线转B样条]; [degree]%d; [knots]%d; [poles]%d\n",
		C.Degree(),
		C.NbKnots(),
		C.NbPoles());

	TopoDS_Vertex Vs, Ve;
	TopExp::Vertices(TopoDS::Edge(E), Vs, Ve);

	gp_Pnt Ps = BRep_Tool::Pnt(Vs);
	gp_Pnt Pe = BRep_Tool::Pnt(Ve);
	TRACE(L"[起点](%f, %f, %f), [终点](%f, %f, %f)\n",
		Ps.X(), Ps.Y(), Ps.Z(), Pe.X(), Pe.Y(), Pe.Z());

}


void CMFCApplication1View::OnCircle2Bspline()
{
	// TODO: 在此添加命令处理程序代码
}


#include "AIS_AnimationCamera.hxx"
void CMFCApplication1View::OnViewAnimation()
{

	Handle(Graphic3d_Camera) myStartState = new Graphic3d_Camera();        //!< Start state of view camera
	Handle(Graphic3d_Camera) myEndState = new Graphic3d_Camera();          //!< End state of view camera

	myStartState->Copy(myView->Camera());
	myEndState->Copy(myView->Camera());

	Handle(AIS_AnimationCamera) myAnimationCamera = new AIS_AnimationCamera("aAnimation", myView);//myViewCube->ViewAnimation();
	Handle(Graphic3d_Camera) aBackupCamera = myView->Camera();
	const bool wasImmediateUpdate = myView->SetImmediateUpdate(false);
	myView->SetCamera(myEndState);
	myView->SetProj(V3d_Xpos, Standard_True);  // 这里将myEndState改成目标相机位姿
	myView->SetCamera(aBackupCamera);		  // 设回原来的相机位姿	
	myView->SetImmediateUpdate(wasImmediateUpdate);

	myAnimationCamera->SetOwnDuration(0.5);
	myAnimationCamera->SetCameraStart(myStartState);
	myAnimationCamera->SetCameraEnd(myEndState);
	myAnimationCamera->StartTimer(0.0, 1.0, true, false);

	for (; myAnimationCamera->IsStopped() != Standard_True; )
	{
		myView->IsInvalidated() ? myView->Redraw() : myView->RedrawImmediate();

		const Standard_Real aPts = myAnimationCamera->UpdateTimer();
		if (aPts >= myAnimationCamera->OwnDuration())
			myViewAnimation->Stop();
	}
}

#include "AIS_My2dShape.h"
#include "AIS_My2dText.h"
void CMFCApplication1View::OnUserDefined2dAisObject()
{
	Handle(AIS_My2dShape) aMy2dShape = new AIS_My2dShape(100, 100, 200, 200);
//	Handle(AIS_My2dText) aMy2dText = new AIS_My2dText(100, -200, "PiteWorks");

	myAisContext->SetZLayer(aMy2dShape, myZLayerID);

	myAisContext->Display(aMy2dShape, Standard_True);
//	myAisContext->Display(aMy2dText, Standard_True);
}

void CMFCApplication1View::UpdateGrid()
{
	Standard_Real vw, vh;
	Standard_Integer w, h;
	myView->Size(vw, vh);
	myView->Window()->Size(w, h);

	if (!myFixedGrid.IsNull())
	{
		myFixedGrid->SetParams(w, h, vw, vh);
		myAisContext->Redisplay(myFixedGrid, Standard_True);
	}
}


void CMFCApplication1View::OnSize(UINT nType, int cx, int cy)
{
	__super::OnSize(nType, cx, cy);

	if (cx != 0
		&& cy != 0
		&& !myView.IsNull())
	{
		myView->Window()->DoResize();
		myView->MustBeResized();

		UpdateGrid();

		myView->Invalidate();
	}
}

#include "GeomAPI_IntCS.hxx"
void CMFCApplication1View::On3dPointTo2dPoint()
{
	//	两个点
	gp_Pnt p(100, 200, 300);
	Handle(Geom_Point) aGeomPoint = new Geom_CartesianPoint(p);
	Handle(AIS_Point) anAisPoint = new AIS_Point(aGeomPoint);
	anAisPoint->SetMarker(Aspect_TOM_X);

	gp_Pnt eye = myView->Camera()->Eye();
	gp_Dir eye_dir = myView->Camera()->Direction();

	// 两点形成一条直线
	Handle(Geom_Line) aGeomLine = new Geom_Line(p, eye_dir);

	//	一个平面
	Standard_Real zNear = myView->Camera()->ZNear();
	gp_Pnt pos = eye.XYZ() + zNear * eye_dir.XYZ();
	gp_Pln aPlane(pos, gp_Vec(eye, p));

	Handle(Geom_Plane) aGeomPlane = new Geom_Plane(aPlane);

	//	线面相交
  // Compute intersection
	GeomAPI_IntCS anIntersector(aGeomLine, aGeomPlane);
	if (!anIntersector.IsDone() || anIntersector.NbPoints() == 0)
		return ;

	gp_Pnt theIntersector =  anIntersector.Point(1);

	Handle(Geom_Point) anotherGeomPoint = new Geom_CartesianPoint(theIntersector);
	Handle(AIS_Point) anotherAisPoint = new AIS_Point(anotherGeomPoint);
	anotherAisPoint->SetMarker(Aspect_TOM_PLUS);

	//	交点投影
	//gp_Pnt p2 = myView->Camera()->ConvertWorld2View(p);
	Standard_Integer xi, yi;
	myView->Convert(p.X(), p.Y(), p.Z(), xi, yi);

	Handle(AIS_My2dShape) an2dShape = new AIS_My2dShape(xi, yi, 100, 100);

	//	视锥平面
	gp_Pln leftPln, rightPln, topPln, bottomPln, nearPln, farPln;
	myView->Camera()->Frustum(leftPln, rightPln, bottomPln, topPln, nearPln, farPln);

	//	显示
	myAisContext->Display(an2dShape, Standard_False);
	myAisContext->Display(anAisPoint, Standard_False);
	myAisContext->Display(anotherAisPoint, Standard_True);
}

void CMFCApplication1View::OnFixedGrid()
{
	Standard_Real vw, vh;
	Standard_Integer w, h;
	myView->Size(vw, vh);
	myView->Window()->Size(w, h);

	if (myFixedGrid.IsNull())
	{
		myFixedGrid = new AIS_MyGrid(w, h, vw, vh);
		myAisContext->Display(myFixedGrid, Standard_True);
	}
	else
	{
		myFixedGrid->SetParams(w, h, vw, vh);
		myAisContext->Redisplay(myFixedGrid, Standard_True);
	}

}

BOOL CMFCApplication1View::OnMouseWheel(UINT theFlags, short theDelta, CPoint thePoint)
{
	Standard_Real oldVW, oldVH, newVW, newVH;
	Standard_Integer w,h;

	myView->Size(oldVW, oldVH);
	myView->Window()->Size(w, h);

	const Standard_Real aDeltaF = Standard_Real(theDelta) / Standard_Real(WHEEL_DELTA);
	CPoint aCursorPnt = thePoint;
	ScreenToClient(&aCursorPnt);
	const Graphic3d_Vec2i  aPos(aCursorPnt.x, aCursorPnt.y);
	const Aspect_VKeyFlags aFlags = WNT_Window::MouseKeyFlagsFromEvent(theFlags);
	if (UpdateMouseScroll(Aspect_ScrollDelta(aPos, aDeltaF, aFlags)))
	{
		UpdateOccView();
	}

	myView->Size(newVW, newVH);

	if (!myFixedGrid.IsNull())
	{
		myFixedGrid->SetParams(w, h, newVW, newVH);
		myAisContext->Redisplay(myFixedGrid, Standard_True);
	}

	TRACE("\n【ZoomRatio】%f\n", oldVW / newVW);

	return true;
}

#include "AIS_PointCloud.hxx"
#include "AIS_MyPointCloud.h"
void CMFCApplication1View::OnPointCloud()
{
	Handle(AIS_MyPointCloud) myPointCloud = new AIS_MyPointCloud();

	Handle(Graphic3d_ArrayOfPoints) ptsArray = new Graphic3d_ArrayOfPoints(4);

	ptsArray->AddVertex(gp_Pnt(0,0,0));
	ptsArray->AddVertex(gp_Pnt(20, 0, 0));
	ptsArray->AddVertex(gp_Pnt(0, 20, 0));
	ptsArray->AddVertex(gp_Pnt(20, 20, 0));

	myPointCloud->SetPoints(ptsArray);

	myAisContext->Display(myPointCloud, Standard_True);


}

#include "gp_Cone.hxx"
#include "GC_MakeConicalSurface.hxx"
#include "CUserFntDlg.h"
void CMFCApplication1View::OnCone()
{
	//gp_Cone cone(gp_Ax3(gp_Pnt(0,0,0), gp_Dir(0,0,1), gp_Dir(1,0,0)), M_PI/4, 50);	//TopoDS_Face Face = BRepBuilderAPI_MakeFace(cone, 0, M_PI, 0, 100).Face();	//Handle(AIS_Shape) aShape = new AIS_Shape(Face);	//myAisContext->Display(aShape, Standard_False);

	//myView->FitAll();

	CUserFntDlg dlg;
	dlg.DoModal();
}

#include "ISession_Surface.h"
void CMFCApplication1View::OnIsoSurface()
{
	Handle(Geom_ConicalSurface) aCone = new Geom_ConicalSurface(gp_Ax3(gp::Origin(), gp::DZ()), M_PI_4, 200);
	Handle(Geom_RectangularTrimmedSurface) aSurface = new Geom_RectangularTrimmedSurface(aCone, 0., M_PI*10, 0., 300);

	Quantity_NameOfColor aNameOfColor = Quantity_NOC_BLACK;
	Handle(ISession_Surface) aGraphicalSurface = new ISession_Surface(aSurface);
	
	myAisContext->SetColor(aGraphicalSurface, aNameOfColor, Standard_False);
	aGraphicalSurface->Attributes()->FreeBoundaryAspect()->SetColor(aNameOfColor);
	aGraphicalSurface->Attributes()->SetUIsoAspect(new Prs3d_IsoAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 2.0f, 10));
	aGraphicalSurface->Attributes()->SetVIsoAspect(new Prs3d_IsoAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 2.0f, 10));

	myAisContext->SetDisplayMode(aGraphicalSurface, 1, Standard_False);
	myAisContext->Display(aGraphicalSurface, Standard_True);
}
